package com.zang.hash;

/**
 * @author ZVerify
 * @since 2022/10/12 10:33
 * @see <a href="https://leetcode.cn/problems/valid-anagram/">...</a>
 **/
public class 有效的字母异位词 {

    public boolean isAnagram(String s, String t) {

        if(s.length()!=t.length()) return false;
        int[] map = new int[26];

        for (char c : s.toCharArray()) {
            map[c-'a']++;
        }
        for (char c : t.toCharArray()) {
            map[c-'a']--;
            if (map[c-'a']<0){
                return false;
            }
        }
        return true;
    }
}
